package com.czx.reflection.controller;

import com.czx.reflection.pojo.Person;

//测试Class类的常见方式有哪些
public class Test02 {
    public static void main(String[] args) throws ClassNotFoundException {
        Person person = new student();
        System.out.println("这是个人"+person.name);
        //方法一：通过对象获得
        Class personClass = person.getClass();
        System.out.println(personClass.hashCode());
        //方法二：forName获得
        Class forName = Class.forName("com.czx.reflection.controller.student");
        System.out.println(forName.hashCode());


    }
}

class student extends Person{
    public student(){
        this.name="学生";
    }
}

class teacher extends Person{
    public teacher(){
        this.name="老师";
    }
}
